package com.example.demo.service;

import com.example.demo.config.CustomConfig;
import com.example.demo.config.DoctorConfig;
import com.example.demo.config.UserConfig;
import com.example.demo.model.Doctor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class AnnoService {

    private final UserConfig userConfig;
    private final CustomConfig customConfig;
    private final DoctorConfig doctorConfig;

    @Autowired
    public AnnoService(UserConfig userConfig, CustomConfig customConfig, DoctorConfig doctorConfig) {
        this.userConfig = userConfig;
        this.customConfig = customConfig;
        this.doctorConfig = doctorConfig;
    }

    public Map<String, String> getDbConfig() {
        return customConfig.getDb();
    }

    public void printUserDetails() {
        System.out.println("doctors msg Configuration: " + doctorConfig.getMessage());

        for (Map.Entry<String, Doctor> entry : doctorConfig.getMembers().entrySet()) {
            String userId = entry.getKey();
            Doctor doctor = entry.getValue();
            System.out.println("User ID: " + userId);
            System.out.println("Name: " + doctor.getName());
            System.out.println("Age: " + doctor.getAge());
            System.out.println("Contacts:");
            doctor.getContacts().forEach((key, value) -> System.out.println("- " + key + ": " + value));
            System.out.println();
        }
    }



    public Map<String, Doctor> getMembers() {
        return doctorConfig.getMembers();
    }

    public void printUsers() {
        System.out.println("Users Configuration: " + userConfig.getUsers());
        System.out.println("Custom Message: " + customConfig.getMessage());
        System.out.println("Custom db: " + customConfig.getDb());

    }



}
